home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6342 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.1 KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c++,comp.lang.c,comp.lang
  4. Subject: Re: Undefined behavior? on type conversion, was: Re: Hungarian notation
  5. Date: Fri, 09 Feb 1996 01:10:30 GMT
  6. Organization: Netcom
  7. Message-ID: <311a98e8.87171105@nntp.ix.netcom.com>
  8. References: <30C40F77.53B5@swsbbs.com> <4d2ok0$69s@beach.and.nl> <4er2qo$h2s@galaxy.ucr.edu> <31118641.6802368@nntp.ix.netcom.com> <4eurpq$b75@news.xmission.com> <31137427.133220928@nntp.ix.netcom.com> <4f975g$g18@news.xmission.com> <31189e62.47294315@nntp.ix.netcom.com> <4fbs3n$31f@news.xmission.com>
  9. NNTP-Posting-Host: ix-dc17-06.ix.netcom.com
  10. X-NETCOM-Date: Thu Feb 08  5:10:10 PM PST 1996
  11. X-Newsreader: Forte Agent .99d/32.182
  12.  
  13. tknarr@xmission.com   ( Todd Knarr ) wrote:
  14.  
  15. > In <31189e62.47294315@nntp.ix.netcom.com>, miker3@ix.netcom.com (Mike Rubenstein) writes:
  16. > >Just as it requires a conversion to be done for (char) 256, even if
  17. > >char is 8 bits.  Again, the standard says a cast does a conversion and
  18. > >this is the correct syntax and valid data for the operation.  Hence a
  19. > >conversion must be done.
  20. > Except that you don't have legal data. 256 is not a legal value for a
  21. > char on machines with an 8-bit char. The question is whether the standard
  22. > defines "result" to mean only ( essentialy ) return value or whether it
  23. > includes outcomes in general.
  24.  
  25. Of course you have legal data.  The standard says you have legal data.
  26. The fact that you don't like it doesn't make it illegal.
  27.  
  28. > The reference section of K&R2 isn't the standard, but it tends to use
  29. > the same language as the standard and it refers to the result of / when
  30. > the second operand is 0 being undefined, and I know many conforming
  31. > compilers cause the program to terminate when you divide by 0, so if
  32. > you're right then K&R2 and the standard use different definitions and
  33. > I haven't seen that to be the case before.
  34.  
  35. There's more to the standard than that section.  The definition of
  36. implementation behavior says that it behavior can only occur for "a
  37. correct program construction and correct data ..."  (ISO 3.10)
  38.  
  39. Are you going to claim that what the standard calls "correct data" is
  40. somehow illegal?  It's going to be very hard to convince me of that.
  41.  
  42. Frankly, I'm beginning to wonder about you.  Why quote K&R2 when
  43. there's a standard?  If you don't have access to a copy, why not get
  44. it and read it before deciding what it says?
  45.  
  46. What does the result of dividing by 0 have to do with anything.  Why
  47. assume that what K&R2 say is the same as what the standard says.  Why
  48. not look at the standard.  You might learn that it does not use that
  49. wording for division by 0.  It says (ISO 6.3.5)
  50.  
  51.     In both operations [/ and %], if the value of the second 
  52.     operand is zero, the behavior is undefined.
  53.  
  54. Do you see the word "result" in that sentence?
  55.  
  56. If you're going to claim that the standard uses the word result as
  57. meaning behavior in general, please cite the standard, not some  book
  58. that you imagine uses the same words.
  59.  
  60. It's clear from the standard that if a program attempts to divide by
  61. 0, it may do anything and the implementor is not required to document
  62. what it does.
  63.  
  64.  
  65. Michael M Rubenstein
  66.